package com.southminority.ethnic.controller.contact.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import com.southminority.ethnic.vo.MapLocationConfigVO;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.math.BigDecimal;

/**
 * 联系信息视图对象
 * 
 * @author SouthMinority
 */
@Data
@Schema(description = "联系信息视图对象")
public class ContactInfoVO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 联系信息ID
     */
    @Schema(description = "联系信息ID", example = "1")
    private Long id;

    /**
     * 联系方式类型
     */
    @Schema(description = "联系方式类型", example = "phone", required = true,
            allowableValues = {"address", "phone", "email", "website", "social"})
    private String type;

    /**
     * 联系方式类型显示名称
     */
    @Schema(description = "联系方式类型显示名称", example = "联系电话", accessMode = Schema.AccessMode.READ_ONLY)
    private String typeDisplay;

    /**
     * 联系方式标题
     */
    @Schema(description = "联系方式标题", example = "实验室联系电话", required = true, maxLength = 100)
    private String title;

    /**
     * 图标类名（FontAwesome）
     */
    @Schema(description = "图标类名（FontAwesome）", example = "fas fa-phone-alt", maxLength = 100)
    private String icon;

    /**
     * 联系方式内容列表（JSON解析后的列表）
     */
    @Schema(description = "联系方式内容列表", 
            example = "[\"办公室: +86-851-83610152\", \"项目合作: +86-851-83610153\"]")
    private List<String> contentList;

    /**
     * 描述信息
     */
    @Schema(description = "描述信息", example = "实验室各类联系电话")
    private String description;

    /**
     * 关联机构ID
     */
    @Schema(description = "关联机构ID", example = "1")
    private Long organizationId;

    /**
     * 是否主要联系方式
     */
    @Schema(description = "是否主要联系方式", example = "true")
    private Boolean isPrimary;

    /**
     * 是否公开显示
     */
    @Schema(description = "是否公开显示", example = "true")
    private Boolean isPublic;

    /**
     * 显示顺序
     */
    @Schema(description = "显示顺序", example = "1", minimum = "0")
    private Integer displayOrder;

    /**
     * 排序
     */
    @Schema(description = "排序", example = "1", minimum = "0")
    private Integer sortOrder;

    /**
     * 关联地图位置配置ID
     */
    @Schema(description = "关联地图位置配置ID", example = "1")
    private Long mapLocationId;

    /**
     * 地图位置配置信息
     */
    @Schema(description = "地图位置配置信息", accessMode = Schema.AccessMode.READ_ONLY)
    private MapLocationConfigVO mapLocation;

    /**
     * 状态显示
     */
    @Schema(description = "状态显示", example = "启用", 
            allowableValues = {"启用", "禁用", "已删除"}, accessMode = Schema.AccessMode.READ_ONLY)
    private String statusDisplay;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间", example = "2024-01-15T09:00:00", accessMode = Schema.AccessMode.READ_ONLY)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Schema(description = "更新时间", example = "2024-01-15T10:30:00", accessMode = Schema.AccessMode.READ_ONLY)
    private LocalDateTime updateTime;

    /**
     * 获取经度
     */
    public BigDecimal getLongitude() {
        return mapLocation != null ? mapLocation.getLongitude() : null;
    }

    /**
     * 获取纬度
     */
    public BigDecimal getLatitude() {
        return mapLocation != null ? mapLocation.getLatitude() : null;
    }

    /**
     * 获取坐标数组 [经度, 纬度] - 用于前端地图组件
     */
    public BigDecimal[] getCoordinates() {
        if (mapLocation != null) {
            return mapLocation.getCoordinates();
        }
        return null;
    }

    /**
     * 是否有地图位置信息
     */
    public Boolean hasMapLocation() {
        return mapLocation != null && mapLocation.getLongitude() != null && mapLocation.getLatitude() != null;
    }
} 